using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace PUCIT.eFCS.DataAccess.Models.Mapping
{
    public class actionMap : EntityTypeConfiguration<action>
    {
        public actionMap()
        {
            // Primary Key
            this.HasKey(t => t.actionId);

            // Properties
            this.Property(t => t.label)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.javascript)
                .IsRequired();

            // Table & Column Mappings
            this.ToTable("action");
            this.Property(t => t.actionId).HasColumnName("actionId");
            this.Property(t => t.sectionId).HasColumnName("sectionId");
            this.Property(t => t.label).HasColumnName("label");
            this.Property(t => t.javascript).HasColumnName("javascript");
            this.Property(t => t.nextSectionId).HasColumnName("nextSectionId");

            // Relationships
            this.HasRequired(t => t.section)
                .WithMany(t => t.actions)
                .HasForeignKey(d => d.sectionId);
            this.HasRequired(t => t.section1)
                .WithMany(t => t.actions1)
                .HasForeignKey(d => d.sectionId);

        }
    }
}
